package cn.tedu.mall.seckill.exception;

import cn.tedu.mall.common.restful.JsonResult;
import cn.tedu.mall.common.restful.ResponseCode;
import cn.tedu.mall.pojo.seckill.dto.SeckillOrderAddDTO;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class SeckillFallbackHandler {
    //访问修饰符是public
    //返回值类型是被限流的方法的返回值类型
    //参数列表：被限流的方法的参数列表，还可以添加Throwable异常
    //还需要static修饰符
    public static JsonResult seckillFallback(String randCode,
                                          SeckillOrderAddDTO seckillOrderAddDTO,
                                          Throwable throwable){
        log.info("一个请求被降级了");
        return JsonResult.failed(ResponseCode.INTERNAL_SERVER_ERROR,throwable.getMessage());
    }
}
